﻿@using Orchard.Fields.Settings
@using Orchard.Utility.Extensions;
@{
    string name = Model.ContentField.DisplayName;
    LinkFieldSettings settings = Model.ContentField.PartFieldDefinition.Settings.GetModel<LinkFieldSettings>();
    string text = Model.ContentField.Text;
    switch(settings.LinkTextMode) {
        case LinkTextMode.Static:
            text = settings.StaticText;
            break;
        case LinkTextMode.Url:
            text = Model.ContentField.Value;
            break;
        case LinkTextMode.Optional:
            if (String.IsNullOrWhiteSpace(text)) {
                text = Model.ContentField.Value;
            }
            break;
    }
}
<p class="link-field link-field-@name.HtmlClassify()">
    <span class="name">@name:</span>
    <span class="value"><a href="@Model.ContentField.Value"@if (!string.IsNullOrWhiteSpace(Model.ContentField.Target)) { <text>target="@Model.ContentField.Target"</text> }>@text</a></span>
</p>
